﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;

public partial class Reportes : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       if (!Page.IsPostBack)
        {
            if (Session["iduser"] == null || Session["iduser"].ToString() == "0")
            {
                Response.Redirect("index.aspx");
            }
            else
            {
            }
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            int dato = int.Parse(txtinfo.Text);

            DataSet ds = new DataSet();
            wcfBolsa.Service1 wb = new wcfBolsa.Service1();
            ds = wb.UnAspiranteRegistro(dato, true);

            DataTable dt = new DataTable();
            dt.TableName = "Candidato";
            dt.Columns.Add("Nombre", typeof(string));
            dt.Columns.Add("Apellidos", typeof(string));
            dt.Columns.Add("FechaNacimiento", typeof(string));
            dt.Columns.Add("Dui", typeof(string));
            dt.Columns.Add("Nit", typeof(string));
            dt.Columns.Add("Nup", typeof(string));
            dt.Columns.Add("isss", typeof(string));
            dt.Columns.Add("Celular", typeof(string));
            dt.Columns.Add("Telefono", typeof(string));
            dt.Columns.Add("Email", typeof(string));


            int j = 0;
            for (int i = 1; i <= ds.Tables[0].Rows.Count; i++)
            {
                dt.Rows.Add(j);
                dt.Rows[j].BeginEdit();
                dt.Rows[j]["Nombre"] = ds.Tables[0].Rows[j][3];
                dt.Rows[j]["Apellidos"] = ds.Tables[0].Rows[j][4];
                dt.Rows[j]["FechaNacimiento"] = ds.Tables[0].Rows[j][5];
                dt.Rows[j]["Dui"] = ds.Tables[0].Rows[j][9];
                dt.Rows[j]["Nit"] = ds.Tables[0].Rows[j][10];
                dt.Rows[j]["Nup"] = ds.Tables[0].Rows[j][11];
                dt.Rows[j]["isss"] = ds.Tables[0].Rows[j][12];
                dt.Rows[j]["Celular"] = ds.Tables[0].Rows[j][13];
                dt.Rows[j]["Telefono"] = ds.Tables[0].Rows[j][14];
                dt.Rows[j]["Email"] = ds.Tables[0].Rows[j][6];
                dt.Rows[j].EndEdit();
                j++;
            }

            GridView1.DataSource = dt; //ds.Tables[0];
            GridView1.DataBind();
        }
        catch (Exception ex)
        {


            EventLog LogErr = new EventLog();
            if (!EventLog.SourceExists("WebContrataci"))
            {
                EventLog.CreateEventSource("WebContrataci", "Application");
                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
            }
            else
            {

                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString());
            }
        }
    }
}